/**
 * 对象选择列表combo
 * 
 * @param {} combolabel
 * @param {} returnIdField
 * @param {} returnNameField
 * @param {} defaultValue
 * @param {} allowBlank
 * @return {}
 */
function getObjectSelectCombo(combolabel, returnIdField, returnNameField,
		defaultValue, allowBlank) {
	var comboWithTooltip = new Ext.form.ComboBox({
				store : new Ext.data.SimpleStore({
							fields : [],
							data : [[]]
						}),
				fieldLabel : combolabel,
				editable : false,
				id : '_oname',
				name : '_oname',
				mode : 'local',
				triggerAction : 'all',
				maxHeight : 200,
				tpl : '<div id="getObjectSelectComboList"></div>',
				selectedClass : '',
				onSelect : Ext.emptyFn,
				allowBlank : (allowBlank == true),
				emptyText : '请选择...'
			});

	var objectListStore = new Ext.data.JsonStore({
				idProperty : 'id',
				remoteSort : false,
				totalProperty : 'totalCount',
				root : 'objectList',
				fields : ['id', 'key', 'name', 'memo', 'handler', 'system',
						'viewdiy'],

				// load using script tags for cross domain, if the data in on
				// the same domain as
				// this page, an HttpProxy would be better
				proxy : new Ext.data.ScriptTagProxy({
							url : context + '/system/object.do?method=list'
						})
			});

	var objectListGrid = new Ext.grid.GridPanel({
				id : 'objectList4SelectGrid',
				store : objectListStore,
				columns : [{
							header : '对象名称',
							width : 100,
							sortable : true,
							dataIndex : 'name'
						}, {
							header : '唯一标识',
							width : 100,
							sortable : true,
							dataIndex : 'key'
						}, {
							header : '对象说明',
							width : 150,
							sortable : false,
							dataIndex : 'memo'
						}, {
							header : '所属系统',
							width : 100,
							sortable : false,
							dataIndex : 'system'
						}],
				stripeRows : true,
				autoExpandColumn : 'iname',
				viewConfig : {
					forceFit : true
				},
				border : false,
				// config options for stateful behavior
				stateful : true,
				stateId : 'grid',
				height : 200,
				loadMask : {
					msg : "数据加载中，请稍等..."
				}
			});

	objectListGrid.on('click', function(e) {
				var t = e.getTarget();
				var v = this.view;
				var rowIdx = v.findRowIndex(t);
				var record = this.getStore().getAt(rowIdx);

				if (record) {
					comboWithTooltip.setValue(record.data.name);
					
					/*调用此方法的js或jsp包含的自定义处理方法*/
					try{
						hasSelectedObject(record.data.key, record.data.name);
					}catch(error){
						
					}
					
					if (Ext.getCmp(returnIdField)) {
						Ext.getCmp(returnIdField)
								.setValue(record.data.key);

					}
					
					if (Ext.getCmp(returnNameField)) {
						Ext.getCmp(returnNameField)
								.setValue(record.data.name);
					}
				}

				comboWithTooltip.collapse();
			});

	comboWithTooltip.on('expand', function() {
				objectListGrid.render('getObjectSelectComboList');

				objectListStore.load({
							params : {
								start : 0,
								limit : pageSize
							}
						});
			});

	return comboWithTooltip;
}